require './subversion_repository'
require './formatter'

def month_before(a_time)
  a_time - 28 * 24 * 60 * 60
end

if $0 == __FILE__
  subsystem_names = %w(jiazhuang.xlsx
                      moban.xls test  keting.docx wit*)
  root = "http://localhost/svn/jiazhuang"

  start_date = month_before(Time.local(2010, 8, 10))
  end_date = Time.now

  repository = SubversionRepository.new(root)
  formatter = Formatter.new

  formatter.report_range(start_date, end_date)

  subsystem_names.each do | name |
    formatter.use_subsystem_with_change_count(name,
      repository.change_count_for(name, start_date))
  end

  puts formatter.output
end